<template>
    <el-row>
        <el-col :span="24">
            <el-form :inline="true"
                :model="supplierSearchObj"
                class="search_prod tl">
                <el-form-item label="">
                    <el-input size="small"
                        clearable
                        v-model="supplierSearchObj.nickname"
                        placeholder="用户昵称"></el-input>
                </el-form-item>
                <el-form-item label="">
                    <el-input size="small"
                        clearable
                        v-model="supplierSearchObj.username"
                        placeholder="会员账号"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-select v-model="supplierSearchObj.is_check"
                        clearable
                        size="small"
                        placeholder="审核状态">
                        <el-option v-for="item in is_checkList"
                            size="small"
                            :key="item.id"
                            :label="item.title"
                            :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label=""
                    class="time_width">
                    <el-date-picker v-model="createTime"
                        type="datetimerange"
                        size="small"
                        align="right"
                        unlink-panels
                        value-format="timestamp"
                        range-separator="-"
                        clearable
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                        :picker-options="pickerOptions2">
                    </el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-row class="tl">
                        <el-col :span="24">
                            <el-button :loading='$store.state.isLoading'
                                size="small"
                                class="top_weiy"
                                type="primary"
                                @click="onSubmit">查询</el-button>
                            <el-button :loading='$store.state.isLoading'
                                size="small"
                                class="top_weiy"
                                type="primary"
                                @click="delSubmit">一键清除</el-button>
                        </el-col>
                    </el-row>
                </el-form-item>
            </el-form>
        </el-col>
    </el-row>
</template>
<script>
export default {
    name: "productSearch",
    data () {
        return {
            pickerOptions2: {
                disabledDate (time) {
                    return time.getTime() > Date.now();
                },
                shortcuts: [
                    {
                        text: "最近一周",
                        onClick (picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                            picker.$emit("pick", [start, end]);
                        }
                    },
                    {
                        text: "最近一个月",
                        onClick (picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                            picker.$emit("pick", [start, end]);
                        }
                    },
                    {
                        text: "最近三个月",
                        onClick (picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                            picker.$emit("pick", [start, end]);
                        }
                    }
                ]
            },

            supplierSearchObj: {
                username: "",
                nickname: "",
                created_time_begin: "",
                created_time_end: "",
                is_check: ''
            },
            createTime: [],
            is_checkList: [{ id: 0, title: "未审核" }, { id: 1, title: "已审核" },{ id: 2, title: "驳回" }]
        };
    },
    methods: {
        delSubmit () {
            this.supplierSearchObj = {
                username: "",
                nickname: "",
                created_time_begin: "",
                created_time_end: "",
                is_check: ''
            };
            this.$emit("sendSearch", this.supplierSearchObj);
        },
        onSubmit () {
            console.log(this.supplierSearchObj);
            this.$emit("sendSearch", this.supplierSearchObj);
        }
    },
    created () { },
    watch: {
        createTime (val) {
            if (val != null) {
                this.supplierSearchObj.created_time_begin = this.$fnc.phptime(val[0]);
                this.supplierSearchObj.created_time_end = this.$fnc.phptime(val[1]);
            } else {
                this.supplierSearchObj.created_time_begin = "";
                this.supplierSearchObj.created_time_end = "";
            }
        }
    }
};
</script>
